var isWx=false;
wx.miniProgram.getEnv(function(res) {
    if(res.miniprogram){
        //小程序
        isWx=true;
    }else{
        isWx=false;
    }
});
function goPaymentCodePage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/paymentCode&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/paymentCode?memberId="+memberId;
    }
}
//首页
function goFistPage(memberId){
    window.location.href="/phone/index?memberId="+memberId;
}
function goAddressFistPage(memberId,addressId){
    window.location.href="/phone/index?memberId="+memberId+"&addressId="+addressId;
}
function goShopPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shop&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/shop?memberId="+memberId;
    }
}

//我的购买袋子记录
function goMyBuySackPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/myBuySack&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/myBuySack?memberId="+memberId;
    }
}
//我的袋子
function goMySackPage(memberId,sackStatus){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/mySack&urlParam=memberId*'+memberId+'#sackStatus*'+sackStatus})
    }else{
        window.location.href="/phone/mySack?memberId="+memberId+"&sackStatus="+sackStatus;
    }
}
//袋子详情
function goMySackDetailPage(memberId,recordId,sackMemberId){
    if (recordId != null && recordId != "null" && recordId != "") {
        if(isWx){
            wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/mySackDetail&urlParam=memberId*'+memberId+'#recordId*'+recordId})
        }else{
            window.location.href="/phone/mySackDetail?memberId="+memberId+"&recordId="+recordId;
        }
    // 去预约页面
    } else {
        if(isWx){
            wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/myDoSackDetail&urlParam=memberId*'+memberId+'#sackMemberId*'+sackMemberId})
        }else{
            window.location.href="/phone/myDoSackDetail?memberId="+memberId+"&sackMemberId="+sackMemberId;
        }
    }
}
//员工处理袋子
function goStaffDoSackPage(memberId,coverStatus){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/staffDoSack&urlParam=memberId*'+memberId+'#coverStatus*'+coverStatus})
    }else{
        window.location.href="/phone/staffDoSack?memberId="+memberId+"&coverStatus="+coverStatus;
    }
}
//袋子详情
function goStaffDoSackDetailPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/staffDoSackDetail&urlParam=memberId*'+memberId+'#id*'+id})
    }else{
        window.location.href="/phone/staffDoSackDetail?memberId="+memberId+"&id="+id;
    }
}
// shop详情
function goItemDetail(memberId, id){
    window.location.href="/phone/shopItemDetail?memberId="+memberId+"&id="+id;
}
//个人中心
function goMyPage(memberId){
    window.location.href="/phone/my?memberId="+memberId;
}
//购买页面
function goBuyPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/buy&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/buy?memberId="+memberId;
    }
}
//付款码
function goPaymentCodePage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/paymentCode&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/paymentCode?memberId="+memberId;
    }
}
//公益宣传
function goGyxcPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/gyxc&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/gyxc?memberId="+memberId;
    }
}
//回收中分类
function goRecoveryMiddleCatPage(memberId,largeCatId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/recoveryMiddleCat&urlParam=memberId*'+memberId+'#largeCatId*'+largeCatId})
    }else{
        window.location.href="/phone/recoveryMiddleCat?memberId="+memberId+"&largeCatId="+largeCatId;
    }
}
//消费记录
function goRecoveryRecordPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/recoveryRecord&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/recoveryRecord?memberId="+memberId;
    }
}
//了解环保金-文章列表
function goWebArticleListPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/webArticleList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/webArticleList?memberId="+memberId;
    }
}

function goTixianListPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/tixianList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/tixianList?memberId="+memberId;
    }
}

function goTixianPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/tixian&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/tixian?memberId="+memberId;
    }
}


//文章详情
function getWebArticleDetailPage(memberId,id) {
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/webArticleDetail&urlParam=memberId*'+memberId+'#id*'+id})
    }else{
        window.location.href="/phone/webArticleDetail?memberId="+memberId+"&id="+id;
    }
}
//客服
function goCallCenterPage(memberId,status){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/callCenter&urlParam=memberId*'+memberId+'#status*'+status})
    }else{
        window.location.href="/phone/callCenter?memberId="+memberId+"&status="+status;
    }
}
//我的环保金
function goMyGoldRecoveryPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/myGoldRecovery&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/myGoldRecovery?memberId="+memberId;
    }
}
//扫码提交页面
function goDebitNotePage(memberId,useMemberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/debitNote&urlParam=memberId*'+memberId+'#useMemberId*'+useMemberId})
    }else{
        window.location.href="/phone/debitNote?memberId="+memberId+"&useMemberId="+useMemberId;
    }
}

// 商城用户地址列表
function goShopAddressListPage(memberId,status){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shopAddressList&urlParam=memberId*'+memberId+'#status*'+status})
    }else{
        window.location.href="/phone/shopAddressList?memberId="+memberId+"&status="+status;
    }
}
// 商城编辑后跳转用户地址列表
function goShopAddressListPageLase(memberId,status){
    if(isWx){
        wx.miniProgram.redirectTo({url: '/pages/index/index?url=/phone/shopAddressList&urlParam=memberId*'+memberId+'#status*'+status})
    }else{
        window.location.href="/phone/shopAddressList?memberId="+memberId+"&status="+status;
    }
}
// 商城用户地址编辑
function goShopAddressAddPage(memberId,status){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shopAddressEdit&urlParam=memberId*'+memberId+'#status*'+status})
    }else{
        window.location.href="/phone/shopAddressEdit?memberId="+memberId+"&status="+status;
    }
}
function goShopAddressEditPage(memberId,addressId,status){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shopAddressEdit&urlParam=memberId*'+memberId+'#addressId*'+addressId+'#status*'+status})
    }else{
        window.location.href="/phone/shopAddressEdit?memberId="+memberId+"&addressId="+addressId+"&status="+status;
    }
}

// 呼叫页面
function goCallOutPage(memberId,largeCatId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/callOut&urlParam=memberId*'+memberId+'#largeCatId*'+largeCatId})
    }else{
        window.location.href="/phone/callOut?memberId="+memberId+"&largeCatId="+largeCatId;
    }
}

// 回收商圈
function goHssqPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/hssq&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/hssq?memberId="+memberId;
    }
}

function goHssqMemberPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/hssqMember&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/hssqMember?memberId="+memberId;
    }
}

// 加入收费员
function goJrsfyPage(memberId){
    if(isWx){
        var latitude=$("#latitude").val();
        var longitude=$("#longitude").val();
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/jrsfy&urlParam=memberId*'+memberId+'#latlong*'+longitude+','+latitude})
    }else{
        window.location.href="/phone/jrsfy?memberId="+memberId;
    }
}

// 投诉
function goComplainPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/complain&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/complain?memberId="+memberId;
    }
}

// 企业下单
function goQyxdPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/qyxd&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/qyxd?memberId="+memberId;
    }
}

// 收废价格
function goSfjgPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/sfjg&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/sfjg?memberId="+memberId;
    }
}

// 回收商圈入驻
function goRecoveryCircleEditPage(memberId){
    if(isWx){
        var latitude=$("#latitude").val();
        var longitude=$("#longitude").val();
        var url='/pages/index/index?url=/phone/recoveryCircleEdit&urlParam=memberId*'+memberId+'#latlong*'+longitude+','+latitude;
        wx.miniProgram.navigateTo({url:url})
    }else{
        window.location.href="/phone/recoveryCircleEdit?memberId="+memberId;
    }
}

function goRecoveryCircleShowPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/recoveryCircleShow&urlParam=memberId*'+memberId+'#id*'+id})
    }else{
        window.location.href="/phone/recoveryCircleShow?memberId="+memberId+"&id="+id;
    }
}

// 收废员审核列表
function goWasteMemberListPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/wasteMemberList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/wasteMemberList?memberId="+memberId;
    }
}

// 根据id查询收废员审核进度
function goWasteMemberShowPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/wasteMemberShow&urlParam=memberId*'+memberId+'#id*'+id})
    }else{
        window.location.href="/phone/wasteMemberShow?memberId="+memberId+"&id="+id;
    }
}

// 回收商圈订单
function goCircleOrderListPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/circleOrderList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/circleOrderList?memberId="+memberId;
    }
}

// 收废员-我的工单
function goCircleOrderMemberListPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/circleOrderMemberList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/circleOrderMemberList?memberId="+memberId;
    }
}

// 根据id查询订单信息
function goCircleOrderShowPage(memberId,id, type){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/circleOrderShow&urlParam=memberId*'+memberId+'#id*'+id+'#type*'+type})
    }else{
        window.location.href="/phone/circleOrderShow?memberId="+memberId+"&id="+id+"&type="+type;
    }
}

// 积分商城
function goJfscPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/jfsc&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/jfsc?memberId="+memberId;
    }
}

// 积分商城详情
function goProductDescPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/productDesc&urlParam=memberId*'+memberId+'#id*'+id})
    }else{
        window.location.href="/phone/productDesc?memberId="+memberId+"&id="+id;
    }
}

// 下单
function goOrderListPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/orderList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/orderList?memberId="+memberId;
    }
}

function goOrderDetailPage(memberId,id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/orderDetail&urlParam=memberId*'+memberId+'#recordId*'+id})
    }else{
        window.location.href="/phone/orderDetail?memberId="+memberId+"&recordId="+id;
    }
}
//跳转
function goJump(url,memberId){
    if(isWx){
        var t=url.split("?");
        var baseUrl=t[0];
        var params=t[1].split("&");
        var paramsStr='memberId*'+memberId;
        for(var i=0;i<params.length;i++){
            var z=params[i].split("=");
            paramsStr+="#"+z[0]+"*"+z[1];
        }
        wx.miniProgram.navigateTo({url: '/pages/index/index?url='+baseUrl+'&urlParam='+paramsStr})
    }else{
        window.location.href=url+"&memberId="+memberId;
    }
}
// 个人资料
function goMemberEditPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/memberEdit&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/memberEdit?memberId="+memberId;
    }
}

// 商城订单列表
function goShopOrderListPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shopOrderList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/shopOrderList?memberId="+memberId;
    }
}

// 商城订单详情
function goShopOrderShowPage(memberId, id){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shopOrderShow&urlParam=memberId*'+memberId+'#id*'+id})
    }else{
        window.location.href="/phone/shopOrderShow?memberId="+memberId+"&id="+id;
    }
}

// 积分列表
function goRecoveryRecordIntegralListPage(memberId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/recoveryRecordIntegralList&urlParam=memberId*'+memberId})
    }else{
        window.location.href="/phone/recoveryRecordIntegralList?memberId="+memberId;
    }
}

// 积分商城下单
function goShopOrderEditPage(memberId, itemId){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/index/index?url=/phone/shopOrderEdit&urlParam=memberId*'+memberId+'#itemId*'+itemId})
    }else{
        window.location.href="/phone/shopOrderEdit?memberId="+memberId+"&itemId="+itemId;
    }
}

function showCardNo(cardNo){
    $.toast("您的卡号：" + cardNo, "text");
}
//客服
function goKeFu(memberId,imgUrl){
    if(isWx){
        wx.miniProgram.navigateTo({url: '/pages/coustom/coustom?imgUrl='+imgUrl})
    }else{

    }
}